package com.itchen.school.common.base;

import com.itchen.school.common.utils.SpringContextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public abstract class BaseController {

    private static final Logger log = LoggerFactory.getLogger(BaseController.class);

    public BaseController() {}

    protected static <TService> TService ref(Class<TService> clazz) {
        return SpringContextUtils.getBean(clazz);
    }

    protected static String encodeQuery(String text) {
        String encodeText = URLEncoder.encode(text, StandardCharsets.UTF_8);
        return encodeText.replace("%", "\\%");
    }

}
